home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 145
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan).7z
/
Gekkan Dennou Club - 2000.6 Vol. 145 (Japan) (Track 1).bin
/
ikap
/
etc
/
f45
/
f45type.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-05-08
|
3KB
|
173 lines
/*
「4x5ドットビットマップフォントを使ってファイル内容をタイプ
(プロプーショナル対応?)
*/
#include <stdio.h>
#include <graph.h>
#include "aspf45.inc" //f45csrc デ コンバート シタ ファイル
/*
patnumのデータ(4x5ドットビットマップ)を指定座標からに表示
パターンの横幅をかえす
*/
int putF45(fx,fy,patnum)
int fx,fy,patnum;
{
int x,y,b,pat;
unsigned char buf[4];
buf[0]=0;
buf[1]=F45pat[patnum][0];
buf[2]=F45pat[patnum][1];
buf[3]=F45pat[patnum][2];
pat=*(int *) (&buf);
b=23;
for( y=0; y<5; y++ ){ ; for( x=0; x<4; x++ ){
if( (pat&(1<<b)) ){
pset(fx+x,fy+y,0xf); //
}
b--;
}}
return((int) F45patWidth[patnum]);
}
/* タブスペース変換:変換後のバイト数を返す
0d,0aとばす
*/
int detab(src,dest)
unsigned char *src,*dest;
{
unsigned char *s,*d;
short x,i,m;
s=src;
d=dest;
x=0;
while( *s ){
switch( *s ){
case '\t':
m=x%8;
if( m==0 ){ m=8; }
for( i=0; i<m; i++ ){
*d++=' ';
x++;
}
break;
case '\x0d':
case '\x0a':
;//とばし
break;
default:
*d++=*s;
x++;
break;
}
s++;
}
*d=0;
return(x);
}
int main(argc,argv)
int argc;
char *argv[];
{
#define BUFSIZE (256)
unsigned char srcbuf[BUFSIZE],destbuf[BUFSIZE]; //@@いいかげん
unsigned char typefile[128];
int x,y,xlen,w,px;
FILE *fp;
int swidth=96,sheight=72; //F502i
int drawoffset_x=0,drawoffset_y=16; //描画開始位置
int nopro=1; //プロポーショナルにしないフラグ
int ac;
typefile[0]=0;
for( ac=1; ac<argc; ac++ ){
if( argv[ac][0]=='/' || argv[ac][0]=='-' ){ ; switch( argv[ac][1] ){
case 'w': case 'W':
sscanf(&argv[ac][2],"%d,%d",&swidth,&sheight);
break;
case 'o': case 'O':
sscanf(&argv[ac][2],"%d,%d",&drawoffset_x,&drawoffset_y);
break;
case 'p': case 'P':
nopro=0; //プロポーショナルにする
break;
}}
else{
//オープンファイル名
strcpy(typefile,argv[ac]);
}
}
if( typefile[0]==0 ){
goto err;
}
screen(2,0,1,1);
window(0,0,767,511);
apage(0);
vpage(0xf);
{
fp=fopen(typefile,"rt");
if( fp==NULL ){
err:
printf(
"4x5ドットフォントを使ったテキストファイル表示(type)\n"
"usage : f45type typefile [option]\n"
"option: /Ww,h 表示領域サイズの設定(def:/W96,72)\n"
" : /Ox,y 描画開始位置の設定(def:/O0,16)\n"
" : /P 指定時のみプロポーショナル表示を行う\n"
);
goto quick_exit;
}
}
x=0;
y=0;
while( feof(fp)==0 ){
fgets(srcbuf,BUFSIZE,fp);
if( srcbuf[0]=='\n' ){
goto next;
}
xlen=detab(srcbuf,destbuf);
x=0;
px=0;
while(1){
for( px=0; px<swidth; ){
if( destbuf[x]==0 ){ goto next; }
w=putF45(px+drawoffset_x,y*6+drawoffset_y,(int) destbuf[x]);
if( nopro ){ w=4; }
px+=(w+1);
x++;
}
y++;
}
next:
y++;
if( y>(sheight/6) ){ break; }
}
{
fclose(fp);
}
quick_exit:
return(0);
}